home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / netinet / ip_var.h < prev    next >
C/C++ Source or Header  |  1995-02-14  |  4KB  |  130 lines

  1. /*
  2.  * Copyright (c) 1982, 1986 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Berkeley.  The name of the
  11.  * University may not be used to endorse or promote products derived
  12.  * from this software without specific prior written permission.
  13.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  *
  17.  *    @(#)ip_var.h    7.5 (Berkeley) 6/29/88 plus MULTICAST 1.0
  18.  */
  19.  
  20. /*
  21.  * Overlay for ip header used by other protocols (tcp, udp).
  22.  */
  23. struct ipovly {
  24.     caddr_t    ih_next, ih_prev;    /* for protocol sequence q's */
  25.     u_char    ih_x1;            /* (unused) */
  26.     u_char    ih_pr;            /* protocol */
  27.     short    ih_len;            /* protocol length */
  28.     struct    in_addr ih_src;        /* source internet address */
  29.     struct    in_addr ih_dst;        /* destination internet address */
  30. };
  31.  
  32. /*
  33.  * Ip reassembly queue structure.  Each fragment
  34.  * being reassembled is attached to one of these structures.
  35.  * They are timed out after ipq_ttl drops to 0, and may also
  36.  * be reclaimed if memory becomes tight.
  37.  */
  38. struct ipq {
  39.     struct    ipq *next,*prev;    /* to other reass headers */
  40.     u_char    ipq_ttl;        /* time for reass q to live */
  41.     u_char    ipq_p;            /* protocol of this fragment */
  42.     u_short    ipq_id;            /* sequence id for reassembly */
  43.     struct    ipasfrag *ipq_next,*ipq_prev;
  44.                     /* to ip headers of fragments */
  45.     struct    in_addr ipq_src,ipq_dst;
  46. };
  47.  
  48. /*
  49.  * Ip header, when holding a fragment.
  50.  *
  51.  * Note: ipf_next must be at same offset as ipq_next above
  52.  */
  53. struct    ipasfrag {
  54. #if BYTE_ORDER == LITTLE_ENDIAN 
  55.     u_char    ip_hl:4,
  56.         ip_v:4;
  57. #endif
  58. #if BYTE_ORDER == BIG_ENDIAN 
  59.     u_char    ip_v:4,
  60.         ip_hl:4;
  61. #endif
  62.     u_char    ipf_mff;        /* copied from (ip_off&IP_MF) */
  63.     short    ip_len;
  64.     u_short    ip_id;
  65.     short    ip_off;
  66.     u_char    ip_ttl;
  67.     u_char    ip_p;
  68.     u_short    ip_sum;
  69.     struct    ipasfrag *ipf_next;    /* next fragment */
  70.     struct    ipasfrag *ipf_prev;    /* previous fragment */
  71. };
  72.  
  73. /*
  74.  * Structure stored in mbuf in inpcb.ip_options
  75.  * and passed to ip_output when ip options are in use.
  76.  * The actual length of the options (including ipopt_dst)
  77.  * is in m_len.
  78.  */
  79. #define MAX_IPOPTLEN    40
  80.  
  81. struct ipoption {
  82.     struct    in_addr ipopt_dst;    /* first-hop dst if source routed */
  83.     char    ipopt_list[MAX_IPOPTLEN];    /* options proper */
  84. };
  85.  
  86. #ifdef MULTICAST
  87. /*
  88.  * Structure stored in an mbuf attached to inpcb.ip_moptions and
  89.  * passed to ip_output when IP multicast options are in use.
  90.  */
  91. struct ip_moptions {
  92.     struct    ifnet   *imo_multicast_ifp;  /* ifp for outgoing multicasts */
  93.     u_char             imo_multicast_ttl;  /* TTL for outgoing multicasts */
  94.     u_char         imo_multicast_loop; /* 1 => hear sends if a member */
  95.     u_short         imo_num_memberships;/* no. memberships this socket */
  96.     struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
  97. };
  98. #endif MULTICAST
  99.  
  100. struct    ipstat {
  101.     long    ips_total;        /* total packets received */
  102.     long    ips_badsum;        /* checksum bad */
  103.     long    ips_tooshort;        /* packet too short */
  104.     long    ips_toosmall;        /* not enough data */
  105.     long    ips_badhlen;        /* ip header length < data size */
  106.     long    ips_badlen;        /* ip length < ip header length */
  107.     long    ips_fragments;        /* fragments received */
  108.     long    ips_fragdropped;    /* frags dropped (dups, out of space) */
  109.     long    ips_fragtimeout;    /* fragments timed out */
  110.     long    ips_forward;        /* packets forwarded */
  111.     long    ips_cantforward;    /* packets rcvd for unreachable dest */
  112.     long    ips_redirectsent;    /* packets forwarded on same net */
  113. };
  114.  
  115. #ifdef    KERNEL
  116. /* flags passed to ip_output as last parameter */
  117. #define    IP_FORWARDING        0x1        /* most of ip header exists */
  118. #ifdef MULTICAST
  119. #define IP_MULTICASTOPTS    0x2        /* multicast opts present */
  120. #endif MULTICAST
  121. #define    IP_ROUTETOIF        SO_DONTROUTE    /* bypass routing tables */
  122. #define    IP_ALLOWBROADCAST    SO_BROADCAST    /* can send broadcast packets */
  123.  
  124. struct    ipstat    ipstat;
  125. struct    ipq    ipq;            /* ip reass. queue */
  126. u_short    ip_id;                /* ip packet ctr, for ids */
  127.  
  128. struct    mbuf *ip_srcroute();
  129. #endif    KERNEL
  130.